package com.sfilyh.servelt.admin;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sfilyh.dao.ArticleDao;
import com.sfilyh.util.StringUtils;


@WebServlet("/bz-admin/listArticle")
public class listArticle extends HttpServlet {	
	private static final long serialVersionUID = 1L;
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String cid =  request.getParameter("cid");
		Integer category = null;
		if(StringUtils.validate(cid)){
			category = Integer.parseInt(cid);
		}
		
		String page =  request.getParameter("page");
		Integer p = null;
		if(StringUtils.validate(page)) p = Integer.parseInt(page);	    
	    
		ArticleDao  articleDao = new ArticleDao();
		
	    request.setAttribute("pb", articleDao.getAllList(p, 15, category, null,new Integer[]{0,1}));
	    request.setAttribute("cid", cid);
	    request.getRequestDispatcher("/WEB-INF/views/admin/listArticle.jsp").forward(request, response);		
		
	}
}
